﻿using Admin.Models;
using Admin.Properties;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Admin.Infra
{
    public class CompanyDBContext
    {
        public MongoDatabase CompanyDatabase;
        //public RequestInfo RequestInfo;

        public CompanyDBContext()
        {
            var client = new MongoClient(Settings.Default.VersionConnectionString);
            var server = client.GetServer();
            CompanyDatabase = server.GetDatabase(Settings.Default.CompanyDatabaseName);
        }

        public MongoCollection<Company> Companies
        {
            get
            {
                return CompanyDatabase.GetCollection<Company>("companies");
            }
        }
    }

    public class VersionDBContext
    {
        public MongoDatabase VersionDatabase;
        //public RequestInfo RequestInfo;

        public VersionDBContext()
        {
            var client = new MongoClient(Settings.Default.VersionConnectionString);
            var server = client.GetServer();
            VersionDatabase = server.GetDatabase(Settings.Default.VersionDatabaseName);
        }

        public MongoCollection<Admin.Models.Version> Versions
        {
            get
            {
                return VersionDatabase.GetCollection<Admin.Models.Version>("versions");
            }
        }
    }

    public class PagesDBContext
    {
        public MongoDatabase PageDatabase;
        //public RequestInfo RequestInfo;

        public PagesDBContext()
        {
            var client = new MongoClient(Settings.Default.VersionConnectionString);
            var server = client.GetServer();
            PageDatabase = server.GetDatabase(Settings.Default.PagesDatabaseName);
        }

        public MongoCollection<Page> Pages
        {
            get
            {
                return PageDatabase.GetCollection<Page>("pages");
            }
        }
    }

    public class PluginsDBContext
    {
        public MongoDatabase PluginDatabase;
        //public RequestInfo RequestInfo;

        public PluginsDBContext()
        {
            var client = new MongoClient(Settings.Default.VersionConnectionString);
            var server = client.GetServer();
            PluginDatabase = server.GetDatabase(Settings.Default.PluginDatabaseName);
        }

        public MongoCollection<Plugin> Plugins
        {
            get
            {
                return PluginDatabase.GetCollection<Plugin>("plugins");
            }
        }
    }

    public class IncludesDBContext
    {
        public MongoDatabase IncludeDatabase;
        //public RequestInfo RequestInfo;

        public IncludesDBContext()
        {
            var client = new MongoClient(Settings.Default.VersionConnectionString);
            var server = client.GetServer();
            IncludeDatabase = server.GetDatabase(Settings.Default.IncludeDatabaseName);
        }

        public MongoCollection<Include> Includes
        {
            get
            {
                return IncludeDatabase.GetCollection<Include>("includes");
            }
        }
    }
}